﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Dqs_BLL;
using Model;
using Sunny.UI;

namespace Dqs_UI
{
	public partial class frmAdmin_Course : UIForm
	{
		public frmAdmin_Course()
		{
			InitializeComponent();
		}
		Course_BLL Course_BLL = new Course_BLL();

		private void frmAdmin_Course_Load(object sender, EventArgs e)
		{
			List<CourseInfo> list = Course_BLL.GetCourses();
			dgvStudentInfo.DataSource = list;
		}

		private void btnInsertAdmin_Click(object sender, EventArgs e)
		{
			frmAddCourse frmAddCourse = new frmAddCourse();
			frmAddCourse.ShowDialog();
			frmAdmin_Course_Load(this, e);
		}

		private void btnUpdateAdmin_Click(object sender, EventArgs e)
		{
			int id = Convert.ToInt32(dgvStudentInfo.SelectedRows[0].Cells["Id"].Value);
			frmUpdateCourse frmUpdateCourse = new frmUpdateCourse(id);
			frmUpdateCourse.ShowDialog();
			frmAdmin_Course_Load(this, e);
		}

		private void btnDeleteAdmin_Click(object sender, EventArgs e)
		{
			int id = Convert.ToInt32(dgvStudentInfo.SelectedRows[0].Cells["Id"].Value);
			Course_BLL.DeleteCourseInfoById(id);
			frmAdmin_Course_Load(this, e);
		}
	}
}
